package com.example.personal.aiagent.common.model.vo;

import com.example.personal.aiagent.common.constant.ErrorCode;
import com.example.personal.aiagent.common.util.StringFormatUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 通用空响应
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonEmptyResponse {
    /**
     * 错误码
     */
    @JsonProperty("error_code")
    private long errorCode = ErrorCode.OK.getErrorCode();

    /**
     * 错误信息
     */
    @JsonProperty("error_msg")
    private String errorMsg = ErrorCode.OK.getErrorMessage();

    public CommonEmptyResponse(ErrorCode errorCode) {
        this.errorCode = errorCode.getErrorCode();
        this.errorMsg = errorCode.getErrorMessage();
    }

    public CommonEmptyResponse(ErrorCode errorCode, List<String> params) {
        this.errorCode = errorCode.getErrorCode();
        this.errorMsg = StringFormatUtils.formatList(errorCode.getErrorMessage(), params);
    }
}
